import { EDominionCountryForce } from "../../../../Message/Public/EDominionCountryForce";
import { Language } from "../../../../extend/language/Language";
import { CityPosInfo } from "./beacon/CityPosInfo";
import { DominionId } from "../../../../Message/Public/DominionId";
import { EntityUtil } from "../../scene/layer/utils/EntityUtil";
import { ProxyConfig } from "../../resource/ProxyConfig";
import { SDominionBattlePreview } from "../../../../Message/Public/SDominionBattlePreview";
import { SDominionBattleSituation } from "../../../../Message/Public/SDominionBattleSituation";
type int = number;
//class DomWarConst
    
    export  class DomWarConst
    {
        

        public static getCampName(arg1: int): string
        {
            var loc1="";
            var loc2=arg1;
            switch (loc2) 
            {
                case EDominionCountryForce._EDominionForceImmortal:
                {
                    loc1 = Language.getString(90617);
                    break;
                }
                case EDominionCountryForce._EDominionForceHumanWorld:
                {
                    loc1 = Language.getString(90618);
                    break;
                }
                case EDominionCountryForce._EDominionForceDevil:
                {
                    loc1 = Language.getString(90619);
                    break;
                }
            }
            return loc1;
        }

        public static getFourCityInfo(arg1: int, arg2: int, arg3: number=839, arg4: number=823): CityPosInfo
        {
            var loc1=null;
            var loc5=null;
            var loc6=null;
            var loc2=new CityPosInfo();
            var loc3=4;
            var loc4=4;
            if (arg1 == loc3 && loc4 - arg2 == 1) 
            {
                loc1 = {"dir": 3, "dist": 269, "pos":{"p": 850}};
            }
            else if (arg1 == loc3 && arg2 - loc4 == 1) 
            {
                loc1 = {"dir": 4, "dist": 255, "pos":{"p": 850}};
            }
            else if (arg2 == loc4 && loc3 - arg1 == 1) 
            {
                loc1 = {"dir": 1, "dist": 180, "pos":{"p": 843}};
            }
            else if (arg2 == loc4 && arg1 - loc3 == 1) 
            {
                loc1 = {"dir": 2, "dist": 278, "pos":{"p": 843}};
            }
            if (loc1) 
            {
                if (arg1 == loc3) 
                {
                    loc1.ratio = -(loc4 - arg2);
                }
                if (arg2 == loc4) 
                {
                    loc1.ratio = -(loc3 - arg1);
                }
            }
            var loc7=0;
            var loc8=loc1;
            for (loc6 in loc8) 
            {
                loc2[loc6] = loc1[loc6];
            }
            return loc2;
        }

        public static getFourCityInfoByDir(arg1: int): CityPosInfo
        {
            var loc1=null;
            var loc2=arg1;
            switch (loc2) 
            {
                case DomWarConst.CITY_DIR_UP:
                {
                    loc1 = DomWarConst.getFourCityInfo(3, 4);
                    break;
                }
                case DomWarConst.CITY_DIR_DOWN:
                {
                    loc1 = DomWarConst.getFourCityInfo(5, 4);
                    break;
                }
                case DomWarConst.CITY_DIR_LEFT:
                {
                    loc1 = DomWarConst.getFourCityInfo(4, 3);
                    break;
                }
                case DomWarConst.CITY_DIR_RIGHT:
                {
                    loc1 = DomWarConst.getFourCityInfo(4, 5);
                    break;
                }
            }
            return loc1;
        }

        public static getXYByGridPos(arg1: int, arg2: int): Object /* flash.geom.Point */
        {
            var loc10=null;
            var loc11=NaN;
            var loc1=new Object /* flash.geom.Point */();
            var loc2=DomWarConst.getFourCityInfoByDir(DomWarConst.CITY_DIR_UP);
            var loc3=DomWarConst.getFourCityInfoByDir(DomWarConst.CITY_DIR_DOWN);
            var loc4=DomWarConst.getFourCityInfoByDir(DomWarConst.CITY_DIR_LEFT);
            var loc5=DomWarConst.getFourCityInfoByDir(DomWarConst.CITY_DIR_RIGHT);
            var loc6=130;
            var loc7=125;
            var loc8=100;
            var loc9=130;
            if (arg1 < 4) 
            {
                loc11 = loc2.ratio * (4 - arg1 - 1) * (loc8 + DomWarConst.CITY_H);
                loc1.y = DomWarConst.MAIN_Y - loc2.dist + loc11;
            }
            else if (arg1 > 4) 
            {
                loc11 = loc3.ratio * (arg1 - 4 - 1) * (loc9 + DomWarConst.CITY_H);
                loc1.y = DomWarConst.MAIN_Y + loc3.dist + loc11;
            }
            else 
            {
                loc1.y = loc4.pos.p;
            }
            if (arg2 < 4) 
            {
                loc11 = loc4.ratio * (4 - arg2 - 1) * (loc6 + DomWarConst.CITY_W / 2);
                loc1.x = DomWarConst.MAIN_X - loc4.dist + loc11;
            }
            else if (arg2 > 4) 
            {
                loc11 = loc5.ratio * (arg2 - 4 - 1) * (loc7 + DomWarConst.CITY_W / 2);
                loc1.x = DomWarConst.MAIN_X + loc5.dist + loc11;
            }
            else 
            {
                loc1.x = loc2.pos.p;
            }
            return loc1;
        }

        public static getInviteTypeName(arg1: int): string
        {
            var loc1="";
            var loc2=arg1;
            switch (loc2) 
            {
                case DomWarConst.INVITE_DEF:
                {
                    loc1 = Language.getString(90662);
                    break;
                }
                case DomWarConst.INVITE_ATK:
                {
                    loc1 = Language.getString(90661);
                    break;
                }
            }
            return loc1;
        }

        public static isInviteAtk(arg1: int): Boolean
        {
            return DomWarConst.INVITE_ATK == arg1;
        }

        public static getSerNameByDomId(arg1: DominionId, arg2: Boolean=true): string
        {
            var loc1="";
            if (arg1) 
            {
                if (EntityUtil.isSameServerByProxyAndServer(arg1.proxyId, arg1.serverId) && arg2) 
                {
                    loc1 = Language.getString(80500);
                }
                else 
                {
                    loc1 = ProxyConfig.instance.getProxyName(arg1.proxyId) + "_s" + arg1.serverId;
                }
            }
            return loc1;
        }

        public static isSameServByDomId(arg1: DominionId): Boolean
        {
            return EntityUtil.isSameServerByProxyAndServer(arg1.proxyId, arg1.serverId);
        }

        public static hasMyServerInPreview(arg1: SDominionBattlePreview): Boolean
        {
            var loc2=null;
            var loc3=undefined;
            var loc4=undefined;
            var loc1=false;
            if (DomWarConst.isSameServByDomId(arg1.mainActId)) 
            {
                loc1 = true;
            }
            else if (DomWarConst.isSameServByDomId(arg1.mainDefId)) 
            {
                loc1 = true;
            }
            else 
            {
                var loc5=0;
                var loc6=arg1.assistActIds;
                for (loc3 in loc6) 
                {
                    loc2 = loc3 as DominionId;
                    if (!(loc2 && DomWarConst.isSameServByDomId(loc2))) 
                    {
                        continue;
                    }
                    loc1 = true;
                    break;
                }
                loc2 = null;
                loc5 = 0;
                loc6 = arg1.assistDefIds;
                for (loc4 in loc6) 
                {
                    loc2 = loc4 as DominionId;
                    if (!(loc2 && DomWarConst.isSameServByDomId(loc2))) 
                    {
                        continue;
                    }
                    loc1 = true;
                    break;
                }
            }
            return loc1;
        }

        public static hasMyServerInSituation(arg1: SDominionBattleSituation): Boolean
        {
            var loc1=false;
            if (DomWarConst.isSameServByDomId(arg1.mainActId)) 
            {
                loc1 = true;
            }
            else if (DomWarConst.isSameServByDomId(arg1.mainDefId)) 
            {
                loc1 = true;
            }
            return loc1;
        }

        public static isSameServer(arg1: DominionId, arg2: DominionId): Boolean
        {
            return arg1.proxyId == arg2.proxyId && arg1.serverId == arg2.serverId;
        }

        public static /* const */CITY_W: number=151;

        public static /* const */CITY_H: number=93;

        public static /* const */MAIN_X: number=839;

        public static /* const */MAIN_Y: number=823;

        public static /* const */CITY_DIR_UP: int=1;

        public static /* const */CITY_DIR_DOWN: int=2;

        public static /* const */CITY_DIR_LEFT: int=3;

        public static /* const */CITY_DIR_RIGHT: int=4;

        public static /* const */INVITE_ATK: int=1;

        public static /* const */INVITE_DEF: int=0;
    }
